Added code to enable type printing #1209
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I have a use case where I'd like to be able to export a string containing the Typescript types for a given Superstruct.
This kinda works, many of the types have a
schema
property in theStruct
class that can be inspected to print the internal types.However, there are quite a few types where this just isn't possible at the moment. For example:
map
,set
, andinstance
types do not pass the nested type into theschema
property of theStruct
class, so this data isn't available after the type is created.Additionally, type modifiers like
optional
,nullable
, anddefault
do not pass any information onto theStruct
class, making it impossible to inspect the presence of these modifiers.To give you an idea of what I'm trying to accomplish, here is the current code that is only partially working:
This pull request makes the minimal necessary changes to complete the function above and get it working for all types.